package com.mashibing.tank;

import java.awt.Graphics;

/**
 * Copyright (C) 2024 - 2024 Jasonakeke， Inc. All Rights Reserved
 *
 * @Desc :
 * @Time : 2024/10/27 15:25
 * @Author : Code_By_Jasonakeke
 * @Email : 2284037977@qq.com
 * @Class : Explode
 * @IDE : IntelliJ IDEA
 */
public class Explode {


	public static final int WIDTH = ResourceMgr.explodes[0].getWidth();

	public static final int HEIGHT = ResourceMgr.explodes[0].getHeight();

	private int x;

	private int y;


	private TankFrame tankFrame;

	private int step = 0;

	public Explode(int x, int y, TankFrame tankFrame) {
		this.x = x;
		this.y = y;
		this.tankFrame = tankFrame;
		new Thread(() -> new Audio("audio/explode.wav").play()).start();
	}


	public void paint(Graphics g) {
		g.drawImage(ResourceMgr.explodes[step++], x, y, WIDTH, HEIGHT, null);
		if (step >= ResourceMgr.explodes.length) {
			tankFrame.explodes.remove(this);
		}
	}

}